using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;

public class ScoreUI : MonoBehaviour
{
    private TextMeshProUGUI scoreTextTMP;

    private void Awake()
    {
        scoreTextTMP = GetComponentInChildren<TextMeshProUGUI>();
    }

    private void OnEnable()
    {
        // 订阅分数更改事件
        StaticEventHandler.OnScoreChanged += StaticEventHandler_OnScoreChanged;
    }

    private void OnDisable()
    {
        // 取消订阅分数更改事件
        StaticEventHandler.OnScoreChanged -= StaticEventHandler_OnScoreChanged;
    }

    // 处理分数更改事件
    private void StaticEventHandler_OnScoreChanged(ScoreChangedArgs scoreChangedArgs)
    {
        // 更新 UI
        scoreTextTMP.text = "得分: " + scoreChangedArgs.score.ToString("###,###0") + "\n精准连击倍率: x" + scoreChangedArgs.multiplier;
    }
}